home *** CD-ROM | disk | FTP | other *** search
- // Listing 1 - Count1 program
-
- #include <cstring.h>
- #include <iomanip.h>
- #include <algo.h>
- #include <map.h>
-
- typedef map< string, long, less<string> > map_t;
-
- int main() {
-
- map_t ct_map;
- string str;
-
- while ( cin >> str ) {
- ct_map.insert( map_t::value_type(str, 0L) );
- ++ct_map[str]; // increment the count
- }
-
- for ( map_t::const_iterator it = ct_map.begin();
- it != ct_map.end(); ++it )
- { cout << setw(7) << (*it).second
- << " - " << (*it).first << endl; }
-
- return EXIT_SUCCESS;
- }
-